#include <bits/stdc++.h>
// 2025/03/09
// tag: 
// Author: Forever
using namespace std;

using int64 = int64_t;

int n, t, cnt[26];

signed main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> t;
    while (t--){
        cin >> n;
        string s;
        cin >> s;
        memset(cnt, 0, sizeof(cnt));
        for (int i = 0; i < n; i++)
            cnt[s[i] - 'a']++;
        pair<pair<int, char>, int> low, high;
        low = high = make_pair(make_pair(cnt[s[0] - 'a'], s[0]), 0);
        for (int i = 0; i < n; i++) {
            low = min(low, make_pair(make_pair(cnt[s[i] - 'a'], s[i]), i));
            high = max(high, make_pair(make_pair(cnt[s[i] - 'a'], s[i]), i));
        }
        s[low.second] = s[high.second];
        cout << s << endl;
    }

    return 0;
}